const Service = require("egg").Service;
const appConfig=require("../../config/appConfig");

class BaseService extends Service {
    constructor(){
        super(...arguments);
        this.tableName="";
        this.pageSize=appConfig.pageSize;
    }
    async getAllList() {
        let result = await this.app.mysql.select(this.tableName, {
            where: {
                isDel: false
            }
        });
        return result;
    }

    /**
     * @name createCountSql 生成count的SQL语句
     * @param {string}} strWhere 查询条件 
     * @returns {string} countSql 生成好的SQL语句
     */
    createCountSql(strWhere){
        let countSql = `select count(*) 'totalCount' from ${this.tableName} where isDel=false ${strWhere} `;
        return countSql;
    }
}

module.exports=BaseService;